//
// Created by vcq on 21/2/9.
//
#pragma once
#include "dbng.hpp"
#include "utils_dao.hpp"
#include <string>
using namespace nlohmann;
using namespace std;
using Dao = dao_t<dbng<mysql>>;
struct user {
    int id;
    string user_login;
    string user_nickname;
    string phone;
    string user_email;
    string user_pass;
    string note;
};
REFLECTION(user, id, user_login, user_nickname,phone, user_email, user_pass,note)

json mgetAllUser(){
    string sql="select * from user";
    Dao dao;
    auto v = dao.query<user>(sql);
    nlohmann::json article_list,ret,item;
    for (auto& o : v) {
        item["id"]=o.id;
        item["user_login"]=o.user_login;
        item["user_nickname"]=o.user_nickname;
        item["phone"]=o.phone;
        item["user_email"]=o.user_email;
        item["note"]=o.note;
        article_list.push_back(item);
    }
    ret["code"]=0;
    ret["count"]=article_list.size();
    ret["data"]=article_list;
    return ret;
}
